<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="../jquery/jquery.min.js"></script>
    <style>
        /* * {
            margin: 0;
            padding: 0;
        }

        body {
            height: 2000px;
        }

        .father {
            position: absolute;
            top: 100px;
            left: 0;
            width: 100%;
            height: 200px;
            background-color: antiquewhite;
        } */
        div {
            position: absolute;
            top: 10px;
            left: 10px;
            width: 30px;
            height: 30px;
            background-color: green;
        }

        button {
            position: absolute;
            top: 20px;
            right: 10px;
        }
    </style>
</head>

<body>
    <div class="father"></div>
    <div></div>
    <!-- <button>执行动画</button> -->
    <button>淡入淡出</button>

    <script>
        // window.onscroll = function () {
        //     console.log($(document).scrollTop());
        // }
        $(function () {
            //执行动画
            // $('button').click(function () {
            //     $('div').animate({ top: '400px', left: '800px' }, 5000)
            // })


            //淡入淡出
            var count = 0;
            $('button').click(function () {
                count++;
                if (count % 2 == 0) {
                    $('div').fadeIn(3000)
                } else {
                    $('div').fadeOut(3000)
                }

            })
        })
    </script>
</body>

</html>